<?php
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); //关闭错误提示
//本文件只做为演示使用，上传的数据结构以交通规范为标准
//端口与地址信息在上传数据时请联系相关人员获取正式地址信息
//@file phpinput_post.php
if($_POST)
{

    $VehicleNo=$_POST['vehicleno'];
    $lng=$_POST['lng'];
    $lat=$_POST['lat'];

    /*    $VehicleNo="6179";
        $lng="118.1";
        $lat="36.1";*/
    $info = array(
        "CompanyId" => '0010',
        "IPCType" => 'PositionVehicle',
        'Source'=>'localphp',
        'positionVehicle'=>[
            [
                "CompanyId" => '0010',
                "VehicleNo" => $VehicleNo,//车牌号牌
                "VehicleRegionCode" => '370030',//行政区划代码
                "PositionTime" => time(),//定位时间
                "Longitude" => $lng, //经度
                "Latitude" => $lat,//纬度
                "Speed" => rand(0, 80), //瞬时速度
                "Direction" => rand(0, 360), //方向角
                "Elevation" => rand(60, 70),//海拔高度(米)
                "Mileage" => 800,//行驶里程
                "Encrypt" => 0, //坐标加密标识
                "WarnStatus" => 0, //预警状态
                "VehStatus" => 0,//车辆状态
                "BizStatus" => 1, //营运状态1 :载客2:接单3 :空驶4 :停运
                "OrderId" => 'D0012', //订单编号
            ],
            [
                "CompanyId" => '0010',
                "VehicleNo" => $VehicleNo,//车牌号牌
                "VehicleRegionCode" => '370030',//行政区划代码
                "PositionTime" => time(),//定位时间
                "Longitude" => $lng, //经度
                "Latitude" => $lat,//纬度
                "Speed" => rand(0, 80), //瞬时速度
                "Direction" => rand(0, 360), //方向角
                "Elevation" => rand(60, 70),//海拔高度(米)
                "Mileage" => 800,//行驶里程
                "Encrypt" => 0, //坐标加密标识
                "WarnStatus" => 0, //预警状态
                "VehStatus" => 0,//车辆状态
                "BizStatus" => 1, //营运状态1 :载客2:接单3 :空驶4 :停运
                "OrderId" => 'D0012', //订单编号
            ]
        ]


    );


    $http_entity_body = json_encode($info);
    $http_entity_type = 'application/x-www-form-urlencoded';
    $http_entity_length = strlen($http_entity_body);
    $host = 'localhost';
    $port = 8001;
    $path = '/api.php/position/vehicle/';

    $fp = fsockopen($host, $port, $error_no, $error_desc, 30);
    if ($fp)
    {
        fputs($fp, "POST {$path} HTTP/1.1\r\n");
        fputs($fp, "Host: {$host}\r\n");
        fputs($fp, "Content-Type: {$http_entity_type}\r\n");
        fputs($fp, "Content-Length: {$http_entity_length}\r\n");
        fputs($fp, "Connection: close\r\n\r\n");
        fputs($fp, $http_entity_body . "\r\n\r\n");

        while (!feof($fp))
        {
            $d .= fgets($fp, 4096);
        }
        fclose($fp);
        echo $d;
        echo "---------------";



    }

}
else
{
    $res=array('code'=>400,'message'=>'请使用post方式提交信息');
    die(json_encode($res));
}


